﻿using System;
using System.Runtime.InteropServices;
using CppUT.Common;

namespace CppUT
{
    namespace NativeMethods
    {
        public static class CppUnitModel
        {
            /// <summary>
            /// Runs all tests associated with the current plugin.
            /// </summary>
            /// <param name="dllPath">Dll path.</param>
            /// <returns>True if tests successful. Otherwise, returns false.</returns>
            [DllImport(Constants.CppunitModelDllName, EntryPoint = "RunAllTests")]
            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool RunAllTests([InAttribute()] [MarshalAs(UnmanagedType.LPStr)] string dllPath);




            [DllImport(Constants.CppunitModelDllName, EntryPoint = "CreateTestRunner")]
            public static extern IntPtr CreateTestRunner();

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "DeleteTestRunner")]
            public static extern void DeleteTestRunner(IntPtr testRunner);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "LoadTests")]
            public static extern void LoadTests(IntPtr testRunner, [MarshalAs(UnmanagedType.LPStr)]string strPluginPath);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "UnloadTests")]
            public static extern void UnloadTests(IntPtr testRunner, [MarshalAs(UnmanagedType.LPStr)]string strPluginPath);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "RunTest")]
            [return: MarshalAs(UnmanagedType.I1)]
            public static extern bool RunTest(IntPtr testRunner, [MarshalAs(UnmanagedType.LPStr)]string strTestPath);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "GetTestRoot")]
            public static extern IntPtr GetTestRoot(IntPtr testRunner);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "GetNoOfChildTests")]
            [return: MarshalAs(UnmanagedType.I4)]
            public static extern int GetNoOfChildTests(IntPtr testObj);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "GetTestChild")]
            public static extern IntPtr GetTestChild(IntPtr testObj, [MarshalAs(UnmanagedType.I4)]int index);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "GetTestName")]
            public static extern IntPtr GetTestName(IntPtr testObj);

            [DllImport(Constants.CppunitModelDllName, EntryPoint = "DeleteStringBuffer")]
            public static extern IntPtr DeleteStringBuffer(IntPtr buffer);
        }
    }
}
